import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { loginApi } from '@/api/userAPi'
import { reqSuccess } from '@/utils'

type User = {
  userName:string
}

export const useLocalUserStore = defineStore('localUser', () => {
  const user = ref<User>({
    userName:''
  })

  const login = (userName:string) => {
    return loginApi(userName)
  }
  const setUser = (userValue:User) => {
    user.value = userValue
  }
  const getUser = ():User => {
    return user.value
  }
  const isLogin = () => {
    return user.value.userName != ''
  }
  return { login, getUser, isLogin, setUser }
})
